package com.eurasia.assignment.controller;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.eurasia.assignment.controller.dto.CourseResponse;
import com.eurasia.assignment.controller.dto.CreateCourseRequest;
import com.eurasia.assignment.domain.Course;
import com.eurasia.assignment.service.CourseService;

/**
 * 课程控制器
 */
@RestController
@RequestMapping("/courses")
public class CourseController {

    private final CourseService courseService;

    public CourseController(CourseService courseService) {
        this.courseService = courseService;
    }

    /**
     * 创建课程
     */
    @PostMapping("")
    public ResponseEntity<CourseResponse> createCourse(@RequestBody CreateCourseRequest request) {
        Course createdCourse = courseService.createCourse(request);
        return ResponseEntity.ok(CourseResponse.fromDomain(createdCourse));
    }
} 